<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>JS写的随机点名_老王</title>
    <script type="text/javascript">
    var isRun=true;
    var a = ["庞钰莹","胡康","曲志强","杨跃东","李元","方志斌"];  
    var a2 = new Array();
    function action(str){
        var s = document.getElementById("bt").value;
        if(s=="开始"){
            isRun=true;
            run();
            document.getElementById("bt").value="结束";
        }else{
            isRun=false;
            document.getElementById("bt").value="开始";
        }
    }
    function run(){
        var i = Math.floor(Math.random() * a.length+ 1)-1;
        document.getElementById("show").innerHTML=a[i];
        if(isRun==false){
            var b =true;
            for(var j in a2){
                if(a2[j]==i){
                    b=false;
                }
            }
            if(b){
                a2[a2.length]=i;
                return;
            }
        }
        setTimeout("run()",10);
    }
</script>
 
</head>
 
<body>
    <div style="text-align:center; margin-top:100px;width:100%;">
        <div id="show" style="margin:auto;font-size:50px;width:150px;height:60px; background:#FFEEFF"></div>
        <div style="margin-top:20px;">
            <input id="bt" type="button" onclick="action();" value="开始"/>
        </div>
    </div>
</body>
</html>